package com.smartcommunity.entity.people;

import lombok.Data;

import static org.apache.commons.lang3.StringUtils.length;

import java.io.Serializable;
import java.sql.Timestamp;

import com.smartcommunity.base.common.CacheMap;
import com.smartcommunity.bean.entity.Village;

/**
 * @ClassName: RealPeopleHouse
 * @Description: 人房关系类
 * @author: minsheng
 * @Date: 2019/1/3 11:44
 * @Company:
 * @version V1.5.0
 */
@Data
public class RealPeopleHouse implements Serializable {
    private static final long serialVersionUID = -1L;

    private Long id;
    /**
     * 小区编号
     */
    private String villageCode;

    /**
     * 证件类型
     */
    private String credentialType;

    /**
     * 证件号
     */
    private String credentialNo;

    /**
     * 楼栋编号
     */
    private String buildingNo;

    /**
     * 单元编号
     */
    private String unitNo;

    /**
     * 房屋编号
     */
    private String houseNo;

    /**
     * 入库或修改时间
     */
    private Timestamp mrowTime;

    /**
     * 房屋类型
     */
    private String type;

    /**
     * 房屋状态：0是正常；1删除
     */
    private int status;

    /**
     *房屋地址
     */
    public String detailAddress;

    private String peopleName;
    private String isHolder;
    private String holdRelation;
    /**
     * 所在辖区名称
     */
    private String orgName;

    /**
     * 房屋迁入迁出状态 1迁入2迁出
     */
    private int move;
    
    /**
     * 是否有权限
     */
    private boolean hasPrivilege = false;
    
    public String concatDetailAddress() {
    	Village village = CacheMap.VILLAGE_INFO_MAP.get(this.getVillageCode());
    	StringBuffer detailAddress = new StringBuffer();
        if (null != village) {
            String villageName = village.getVillageName();
            String buildingNo = this.getBuildingNo();
            String unitNo = this.getUnitNo();
            String houseNo = this.getHouseNo();
            if(length(villageName)>0) {
            	detailAddress.append(villageName);
            }
            if(length(buildingNo)>0) {
            	detailAddress.append(buildingNo).append("栋");
            }
            if(length(unitNo)>0) {
            	detailAddress.append(unitNo).append("单元");
            }
            if(length(houseNo)>0) {
            	detailAddress.append(houseNo).append("室");
            }
        }
        return detailAddress.toString();
    }

}
